<script setup>
import { ref, onMounted } from 'vue'
import { getIndexBannerService } from '@/apis/home'
// 存储轮播图
const bannerList = ref([])

// 获取轮播图
const getBannerList = async () => {
  const res = await getIndexBannerService()
  bannerList.value = res.data.carousels
}

onMounted(() => {
  getBannerList()
})
</script>
<template>
  <div class="banner">
    <el-carousel :interval="4000" type="card" height="400px">
      <el-carousel-item v-for="item in bannerList" :key="item.id">
        <img :src="item.url" class="carousel-image" />
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<style lang="scss" scoped>
.banner {
  margin: 20px 0;

  .carousel-image {
    width: 100%;
    height: 100%;
  }
}
</style>
